//
//  SWPSUtil.h
//  swp
//
//  Created by Rune Laugesen on 31/01/12.
//  Copyright 2012 Copenhagen University. All rights reserved.
//

#ifndef swp_SWPSUtil_h
#define swp_SWPSUtil_h

#define LINEBUFFER 256

#include <fstream>
#include "Instances.h"
#include "CONLLConverter.h"

using namespace std;

struct Feature
{
    int offset;
    int index;
    double weight;
};

/*
 * SMS Word Prediction Structure
 * 0[0] word that needs to be predicted
 * -1[1][2.8] second element e.g. POS tag from previous word and should be weighted 2.8 relative to 1.0
 * 0[0][1.8]/-1[1]/-2[2]/-1[3]/-1[4]
 */
struct SWPS
{
    // Number of features
    int featurecount;
    
    // Number of indices
    int tokencount;
    
    // Raw feature string from file/configuration
    string featurestring;
    
    // Features broken up to individual features
    vector<Feature> features;
};

class SWPSUtil
{
private:
    static string StringToLower(string strToConvert);
public:
    // Obsolete? for some reason no
    static SWPS ReadSWPS(string filename);
    // Config file - read which features should be used EG: NGRAM=2 (bi-gram), WORDCLASS=2 (last two word classes)
    static SWPS ReadSWPSConfig(string filename);
    static vector< vector<string> > ReadSWPSData(string filename, SWPS swps);
    static map<string, vector<string> > ReadSWPSFeatureData(string filename, SWPS swps);
    static vector< vector<string> > ReadCONLLData(string filename);
    static vector< vector<string> > ReadSwitchBoardData(string filename, SWPS swps);
    // Add features to the framework, such that up to 10 features can be read from the SWPS config file
    // Think about building in weight of features, eg bi-gram has lower weight than lemma - numpy.random (math.random)
    // http://www.cplusplus.com/reference/clibrary/cstdlib/rand/
    static vector< vector<string> > buildFeatures(string filename, SWPS swps);
};


#endif
